package com.yykj.user.center.server.controller;

import com.yykj.common.vo.ResultVO;
import com.yykj.user.center.server.form.AppointmentInspectForm;
import com.yykj.user.center.server.form.InspectApplyForm;
import com.yykj.user.center.server.form.PatientAppointmentInspectForm;
import com.yykj.user.center.server.service.InspectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author chenl
 * @version 1.0
 * @date 2021/11/9 17:32
 */
@Api(tags = "检查检验相关接口")
@RestController
@RequestMapping("/api/inspect")
@SuppressWarnings("unchecked")
public class InspectController {

    @Autowired
    private InspectService inspectService;

    @PostMapping("/apply")
    @ApiOperation(value = "医生端app-消息中心-检查/检验申请", notes = "消息中心-检查/检验申请")
    public ResultVO apply(@Valid @RequestBody InspectApplyForm inspectApplyForm) {
        return ResultVO.success(inspectService.apply(inspectApplyForm));
    }

    @GetMapping("/info")
    @ApiOperation(value = "医生端app-消息中心-检查/检验申请-详情", notes = "消息中心-检查/检验申请-详情")
    public ResultVO info(@RequestParam(value = "id", required = true) String id) {
        return ResultVO.success(inspectService.info(id));
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "current", value = "当前页", required = false, dataType = "Integer"),
            @ApiImplicitParam(name = "size", value = "每页显示的条数", required = false, dataType = "Integer"),
            @ApiImplicitParam(name = "startDate", value = "开始日期", required = false, dataType = "String"),
            @ApiImplicitParam(name = "endDate", value = "结束日期", required = false, dataType = "String"),
            @ApiImplicitParam(name = "patientName", value = "患者姓名", required = false, dataType = "String"),
            @ApiImplicitParam(name = "itemName", value = "项目名称", required = false, dataType = "String"),
            @ApiImplicitParam(name = "orderType", value = "类型：1检查 2检验", required = false, dataType = "Integer"),
            @ApiImplicitParam(name = "patientCardId", value = "就诊卡ID", required = false, dataType = "String"),
            @ApiImplicitParam(name = "state", value = "状态1：待预约 2：审核中 3：待检查 4已完成 5已取消", required = false, dataType = "Integer"),
            @ApiImplicitParam(name = "doctorId", value = "医生Id", required = false, dataType = "String"),
    })
    @ApiOperation(value = "检查检验列表", notes = "检查检验列表")
    @GetMapping("/inspectList")
    public ResultVO inspectList(@RequestParam(value = "current", required = false,defaultValue = "1") Integer current,
                                @RequestParam(value = "size", required = false,defaultValue = "1000") Integer size,
                                @RequestParam(value = "startDate", required = false) String startDate,
                                @RequestParam(value = "endDate", required = false) String endDate,
                                @RequestParam(value = "patientName", required = false) String patientName,
                                @RequestParam(value = "itemName", required = false) String itemName,
                                @RequestParam(value = "orderType", required = false) Integer orderType,
                                @RequestParam(value = "patientCardId", required = false) String patientCardId,
                                @RequestParam(value = "state", required = false) Integer state,
                                @RequestParam(value = "doctorId", required = false) String doctorId,
                                @RequestParam(value = "hospitalId", required = false) Integer hospitalId) {
        return ResultVO.success(inspectService.inspectList(current,size,startDate,endDate,patientName,itemName,orderType,patientCardId, state,doctorId,hospitalId));
    }

    @PostMapping("/appointment")
    @ApiOperation(value = "医生端点击预约", notes = "医生端点击预约")
    public ResultVO appointment(@Valid @RequestBody AppointmentInspectForm appointmentInspectForm) {
        return ResultVO.success(inspectService.appointment(appointmentInspectForm));
    }

    @PostMapping("/removeAppointment")
    @ApiOperation(value = "取消预约", notes = "取消预约")
    public ResultVO removeAppointment(@Valid @RequestBody AppointmentInspectForm appointmentInspectForm) {
        return ResultVO.success(inspectService.removeAppointment(appointmentInspectForm));
    }

    @PostMapping("/patientAppointment")
    @ApiOperation(value = "患者端点击预约", notes = "患者端点击预约")
    public ResultVO patientAppointment(@Valid @RequestBody PatientAppointmentInspectForm patientAppointmentInspectForm) {
        return ResultVO.success(inspectService.patientAppointment(patientAppointmentInspectForm));
    }
}
